package com.holystone.orca.util.systemInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

public class SystemInfoUtil {
    
    /**
     * @desc:计算 系统运算时间
     * @author qijunxing
     * @date 2017年7月17日下午4:43:01
     * @return
     */
    public static String getdateTime() {
    	//获取启动时间戳
      	RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
        long startTime = mxBean.getStartTime();    
        Date date = new Date(startTime);  //时间戳时间
        Date nowdate = new Date();//当前时间
        SimpleDateFormat formatter =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
        //两时间差,精确到毫秒   
        long diff = nowdate.getTime() - date.getTime();  
        long day = diff / 86400000;                         //以天数为单位取整  
        long hour= diff % 86400000 / 3600000;               //以小时为单位取整  
        long min = diff % 86400000 % 3600000 / 60000;       //以分钟为单位取整  
        long seconds = diff % 86400000 % 3600000 % 60000 / 1000;   //以秒为单位取整  
        //天时分秒  
        System.out.println("两时间差---> " +day+"天"+hour+"小时"+min+"分"+seconds+"秒");
        System.out.println(formatter.format(date)+""+formatter.format(new Date()));
        
		return day+"天"+hour+"小时"+min+"分";
	}
    
    public static void main(String[] args) {
    	getdateTime() ;
	}
}
